Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 22, 2026

The createZip function had incomplete error handling: both 'close' and 'error' events could fire simultaneously causing double resolution, and errors from intermediate streams in the pipe chain were not handled, risking unhandled rejections.

Changes:

  • Added settled flag to prevent double promise resolution/rejection
  • Attached explicit error handlers to all streams in the pipe chain (zipFile.outputStream, progressStream, outputStream)
  • Implemented cleanup via destroy() on all streams when errors occur

Before:

zipFile.outputStream
  .pipe(progressStream)
  .pipe(outputStream)
  .on('close', () => resolve())
  .on('error', reject)

After:

const handleError = (error: Error) => {
  if (settled) return
  settled = true
  zipFile.outputStream.destroy()
  progressStream.destroy()
  outputStream.destroy()
  reject(error)
}

zipFile.outputStream.on('error', handleError)
progressStream.on('error', handleError)
outputStream.on('error', handleError)
outputStream.on('close', handleSuccess)

zipFile.outputStream
  .pipe(progressStream)
  .pipe(outputStream)

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 22, 2026 12:07
Co-authored-by: madebydavid <5401249+madebydavid@users.noreply.github.com>
Co-authored-by: madebydavid <5401249+madebydavid@users.noreply.github.com>
Copilot AI changed the title [WIP] Update progress tracking for zipping and uploading feature Fix incomplete error handling in createZip stream pipeline Jan 22, 2026
Copilot AI requested a review from madebydavid January 22, 2026 12:11
@madebydavid madebydavid marked this pull request as ready for review January 22, 2026 12:13
@madebydavid madebydavid merged commit 739cf6b into 138-feature-some-progress-indication-of-the-upload-progress-in-default-ship-mode-and-follow-ship-mode Jan 22, 2026
@madebydavid madebydavid deleted the copilot/sub-pr-139-another-one branch January 22, 2026 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants